package com.kaishengit.web;

import java.util.Map;

import com.kaishengit.entity.User;
import com.kaishengit.service.UserService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class AppAction extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	//private Map<String, Object> session;
	private User user;
	private UserService userService = new UserService();

	public String execute() {
		System.out.println("excute");
		return "success";
	}

	@Override
	public void validate() {
		System.out.println("validate");
	}

	public String login() {

		User loginUser = userService.login(user);

		if (loginUser == null) {
			return "login";
		} else {
			Map<String, Object> session=ActionContext.getContext().getSession();
			session.put("currUser", loginUser);
			return "success";
		}
	}

	
	

	// set get
	
	
	
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

}
